package com.zisu.fastdfs.service.impl;

import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import com.zisu.fastdfs.FastdfsApplication;
import com.zisu.fastdfs.service.FdfsService;
import org.omg.CORBA.PRIVATE_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class FdfsServiceImpl implements FdfsService {

    @Autowired
    private FastFileStorageClient fastFileStorageClientl;

    @Override
    public String upload(MultipartFile file,String fileExtName) throws Exception {
        //fileExtName 是后缀名
        StorePath storePath = fastFileStorageClientl.uploadFile(file.getInputStream(),
                file.getSize(),
                fileExtName,
                null
        );
        return storePath.getFullPath();
    }
}
